package com.lagou.controller;

import com.lagou.entity.Tbuser;
import com.lagou.service.TbuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author mcl
 * @date 2021/11/13 13:24
 * @description
 */
@RestController
@RequestMapping("tbuser")
public class TbuserController {

    @Resource
    private TbuserService tbuserService;

    @GetMapping("/list")
    public List<Tbuser> list(@RequestParam String name) {
        Tbuser tbuser = new Tbuser();
        tbuser.setUsername(name);
        return tbuserService.findByTbUser(tbuser);
    }

    @PostMapping("/save")
    public String save(@RequestBody Tbuser tbuser) {
        tbuserService.save(tbuser);
        return "success";
    }
}
